package org.ielts.service;

import org.ielts.domain.base.Campus;
import org.ielts.repository.CampusRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
public class CampusService{

	@Autowired
	CampusRepository campusRepository;

	@Transactional
	public Campus createCampus(String name) {
		Campus campus = new Campus();
		campus.setName(name);

		campusRepository.save(campus);

		return campus;
	}

	@Transactional
	public Campus findCampusByName(String name) {
		Campus campus = campusRepository.findOneByName(name);

		return campus;
	}

	@Transactional
	public Iterable<Campus> findAll() {
		Iterable<Campus> campuses = campusRepository.findAll();
		return campuses;
	}

	@Transactional
	public Campus findOne(String campusId) {
		Campus campus = campusRepository.findOne(campusId);

		return campus;
	}
}
